<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
        }
        .login-container {
            max-width: 400px;
            margin: 100px auto;
            padding: 20px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .form-title {
            text-align: center;
            margin-bottom: 20px;
            color: #333;
        }
        .error-message {
            color: #dc3545;
            text-align: center;
            margin-bottom: 15px;
        }
        .success-message {
            color: #28a745;
            text-align: center;
            margin-bottom: 15px;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="login-container">
        <h2 class="form-title">用户登录</h2>

        <!-- 错误消息 -->
        <div th:if="${error != null}" class="error-message">
            <p th:text="${error}"></p>
        </div>

        <!-- 成功消息 -->
        <div th:if="${message != null}" class="success-message">
            <p th:text="${message}"></p>
        </div>

        <!-- 注册成功消息 -->
        <div th:if="${param.registered != null}" class="success-message">
            <p>注册成功，请登录</p>
        </div>

        <form th:action="@{/login}" method="POST">
            <div class="mb-3">
                <label for="username" class="form-label">用户名</label>
                <input type="text" class="form-control" id="username" name="username" required>
            </div>
            <div class="mb-3">
                <label for="password" class="form-label">密码</label>
                <input type="password" class="form-control" id="password" name="password" required>
            </div>
            <div class="mb-3 form-check">
                <input type="checkbox" class="form-check-input" id="remember" name="remember-me">
                <label class="form-check-label" for="remember">记住我</label>
            </div>
            <button type="submit" class="btn btn-primary w-100">登录</button>
        </form>
        <div class="mt-3 text-center">
            <a href="#">忘记密码？</a> | <a href="/register">注册账号</a>
        </div>
    </div>
</div>

<!-- Bootstrap 5 JS (可选) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>